/******************************************************************************
 * Copyright 2024 zhangcong. All Rights Reserved.
 *****************************************************************************/

#include "business/recordbusiness/proto/store_task_proto.h"
#include "common/common_log.h"

StoreTaskProto *StoreTaskProto::m_instance = nullptr;

StoreTaskProto *StoreTaskProto::GetInstance() {
  if (nullptr == m_instance) {
    m_instance = new StoreTaskProto();
  }
  return m_instance;
}

int32_t StoreTaskProto::DeSerialize(const uint8_t *recvData, const int32_t recvSize) {
  try {
    m_platcmd = json::parse(recvData, recvData + recvSize);
  } catch (const json::parse_error &) {
    Common_Log_e("parse platcmd error");
    return -1;
  } catch (const json::out_of_range &) {
    Common_Log_e("parse platcmd error, outofrange");
    return -1;
  }

  return 0;
}

void StoreTaskProto::GetPlatCmd(json &platcmd) { platcmd = m_platcmd; }